package pms.Biz.impl;

import pms.Biz.SaleBiz;
import pms.dao.SaleDao;
import pms.dao.impl.SaleDaoImpl;
import pms.entity.Sale;

import java.util.List;

public class SaleBizImpl implements SaleBiz {
    private SaleDao saleDao=new SaleDaoImpl();
    @Override
    public boolean addsaleForLeave(Sale sale) {
        if (saleDao.querysaleBySaleForLeave(sale)) {
            //如果有则无法登记
            System.out.println("已登记过此销售记录");
            return false;
        } else {
            return saleDao.addSaleForLeave(sale);
        }

    }

    @Override
    public List<Sale> getsaleByEmpidForLeave(int empid) {
        return null;
    }

    @Override
    public boolean deletesale(int medicineid, int customerid, int empid) {
        if (saleDao.querysaleByMCEForLeave(medicineid,customerid,empid)) {
            //如果有则删除
            System.out.println("此退货记录删除成功");
            return saleDao.deleteSaleForLeave(medicineid,customerid,empid);

        } else {
            System.out.println("此退货记录删除失败");
            return false;

        }
    }
}
